package com.devbobcorn.nekoration.blocks;

import javax.annotation.Nonnull;

import com.devbobcorn.nekoration.NekoColors;
import com.devbobcorn.nekoration.items.DyeableWoodenBlockItem;

import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.item.ItemStack;
import net.minecraft.world.BlockView;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.state.StateManager;

public class WindowBlock extends DyeableVerticalConnectBlock {
    public WindowBlock(Settings settings) {
        super(settings);
        this.setDefaultState(this.stateManager.getDefaultState().with(COLOR, 2));
    }
    
    public WindowBlock(Settings settings, ConnectionType tp, boolean co) {
        super(settings, tp, co);
        this.setDefaultState(this.stateManager.getDefaultState().with(COLOR, 2));
    }

    protected void appendProperties(StateManager.Builder<Block, BlockState> s) {
        s.add(CONNECTION, COLOR);
    }

    @Override
    public boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) {
        if (stateFrom.isOf(this)) {
            return true;
        }
        return false; // TODO Check validity
    }

    @Override
    public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) {
       return 0.5F;
    }
 
    @Override
    public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
       return true;
    }

    @Nonnull
    @Override
    //public ItemStack getPickStack(@Nonnull BlockState state, HitResult target, @Nonnull BlockView world, @Nonnull BlockPos pos, PlayerEntity player) {
    public ItemStack getPickStack(@Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull BlockState state) {
        ItemStack stack = new ItemStack(this.asItem());
        DyeableWoodenBlockItem.setColor(stack, NekoColors.EnumWoodenColor.getColorEnumFromID(state.get(COLOR).byteValue()));
        return stack;
    }
}
